import {Tooltip, ActionIcon, Stack, Alert, Mark, Switch} from "@mantine/core";
import {modals} from "@mantine/modals";
import {notifications} from "@mantine/notifications";
import {IconAlertTriangle} from "@tabler/icons-react";
import React from "react";

export const IpdSimuErr = ({disabled}: {disabled: boolean}) => {
  return (
    <Tooltip
      label="故障轮询配置"
      withArrow
      position="bottom"
      transitionProps={{transition: "fade", duration: 300}}
    >
      <ActionIcon
        variant="light"
        color="red"
        disabled={disabled}
        onClick={() => {
          modals.openConfirmModal({
            title: "故障轮询配置",
            children: (
              <Stack>
                <Alert variant="light" color="red" icon={<IconAlertTriangle size={16} />}>
                  故障轮询是指，遍历<Mark c="red">单一节点脱网</Mark>、
                  <Mark c="red">单一局向中断</Mark>
                  的所有情况，取诸结果的最大值作为仿真结果。
                </Alert>
                <Switch
                  defaultChecked={false}
                  label="启用故障轮询功能"
                  description="该功能将大大增加仿真时间"
                />
              </Stack>
            ),
            labels: {confirm: "确定", cancel: "取消"},
            onCancel: () => console.log("Cancel"),
            onConfirm: () => {
              console.log("Confirmed");
              notifications.show({
                color: "green",
                title: "故障轮询功能配置",
                message: "故障轮询功能已启用/已关闭",
              });
            },
          });
        }}
      >
        <IconAlertTriangle size={16} />
      </ActionIcon>
    </Tooltip>
  );
};
